<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<include file="public:headtop" />
	<script charset="utf-8" src="__STATIC__/weixin/js/goodsinfo.js" type="text/javascript"></script>
	<script charset="utf-8" src="__STATIC__/weixin/js/jquery.js" type="text/javascript"></script>
	<script charset="utf-8" src="__STATIC__/weixin/js/colorbox.js" type="text/javascript"></script>
	<link type="text/css" rel="stylesheet" href="__STATIC__/weixin/colorbox.css">
</head>
<body>
	<include file="public:head" />
	<div class="s_bottom"></div>
	<script type="text/javascript">
		$(function(){
			$("div.module_special .wrap .major ul.list li:last-child").addClass("remove_bottom_line");
		});
		var active=0,
			as=document.getElementById('pagenavi').getElementsByTagName('a');
			
		for(var i=0;i<as.length;i++){
			(function(){
				var j=i;
				as[i].onclick=function(){
					t2.slide(j);
					return false;
				}
			})();
		}
		var t2=new TouchSlider({id:'sliderlist', speed:600, timeout:6000, before:function(index){
				as[active].className='';
				active=index;
				as[active].className='active';
			}});
	</script>

<div id="content">
	<script type="text/javascript">
	    function buys()
	    {
	    	var goodId = $("#goodId").val();
	        var quantity = $("#quantity").val();

	        var size =  $("#sizeChoose").val();
	        var color = $("#colorChoose").val();
            if(check_buy()){
	        add_cart(goodId, quantity, size, color);
            }
	    }
	    
	    function add_cart(goodId,quantity,size,color)//商品ID，购买数量
	    {
	    	
	     	var url  = "{:U('shopcart/add_cart')}";
	     	$.post(url,{goodId:goodId,quantity:quantity,size:size,color:color},function(data){
	     		//alert(data.msg);
	     		if(data.status==1)
	     		{
	     			//$('.dialog_title').html(data.msg);
	     			//$('.bold_num').text(data.count);
	     			//$('.enter').shoping();
	     			$('.J-shoping-num').text(data.count);
	     			//$('.bold_mly').html(data.sumPrice);
	     			//$('.ware_cen').slideDown('slow');
	     			//setTimeout(slideUp_fn, 3000);
	     			$('.add-g-s').fadeIn(200);
	     			setTimeout(addHide,3000);
	     		}else
	     		{
	     			//$('.dialog_title').html("<font color='red'>"+data.msg+"</font>");
	     			//$('.bold_num').text(data.count);
	     			$('.J-shoping-num').text(data.count);
	     			//$('.bold_mly').html(data.sumPrice);
	     			//$('.ware_cen').slideDown('slow');
	     			//setTimeout(slideUp_fn, 3000);	     			
	     		}
	     	},"json");	
	    }
	    function addHide(){
	    	$('.add-g-s').fadeOut("slow");
	    }
	    function buy_now(){
	    	if(check_buy()){
	    	document.getElementById('form1').action="{:U('shopcart/item_buy',array('tokenTall'=>$tokenTall))}";
	    	document.getElementById('form1').submit();
	    	}
	    }
	    function check_buy(){
	    	var goodId = $("#goodId").val();
	        var quantity = $("#quantity").val();

	        var size =  $("#sizeChoose").val();
	        var color = $("#colorChoose").val();
	        //alert(size);

	        if (size == "")
	        {
	            alert('请选择大小');
	            return false;
	        }

	        if (color == "")
	        {
	            alert('请选择颜色');
	            return false;
        	}
	        
	        
	        if (quantity == '')
	        {
	            alert('请输入购买数量');
	            return false;
	        }
	        if (parseInt(quantity) < 1)
	        {
	            alert("购买数量不能小于1");
	            return false;
	        }
	        if(isNaN(quantity))
	        {
	          alert("请输入数字!");
	           return false;
	        }
	        return true;
	    }
		//xxl start
		function showinfo(sheetnum)
		{
			if (sheetnum == 2){
				$("#item_comments").show();
				$("#item_info").hide();
				$("#sheet2").addClass("active");
				$("#sheet1").removeClass("active");
			}else{
				$("#item_comments").hide();
				$("#item_info").show();
				$("#sheet1").addClass("active");
				$("#sheet2").removeClass("active");			
			}
		 
		}
		//xxl end	    
	    /* add cart */
	    function add_to_cart(spec_id, quantity)
	    {
	        var url = SITE_URL + '/index.php?app=cart&amp;act=add';
	        $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
	            if (data.done)
	            {
	                $('.bold_num').text(data.retval.cart.kinds);
	                $('.bold_mly').html(price_format(data.retval.cart.amount));
	                $('#n_3 i').css({display:"block"});
	                $('#n_3 i').text(data.retval.cart.kinds);
	                $('.ware_cen').slideDown('slow');
	                setTimeout(slideUp_fn, 5000);
	            }
	            else
	            {
	                //alert(data.msg);
	                $('.ware_center').html('&lt;h1&gt;'+data.msg+'&lt;/h1&gt;&lt;a class="enter" href="http://store.weiapps.cn/index.php?app=cart&amp;store_id=9"&gt;现在去结算&lt;/a&gt;');
	                $('.ware_cen').slideDown('slow');
	                setTimeout(slideUp_fn, 5000);
	            }
	        });
	    }

		function minus(){
			var quantity = $("#quantity").val();
			//alert(quantity);
			var qty = parseInt(quantity);
			//alert(qty);
			if(qty > 0){
				qty = qty - 1;
				//alert(qty);
				$("#quantity").val(qty);
			}
		}
		function plus(){
			var quantity = $("#quantity").val();
			//alert(quantity);
			var qty = parseInt(quantity);
			//alert(qty);
			qty = qty + 1;
			//alert(qty);
			$("#quantity").val(qty);
			
		}
		
		$(document).ready(function(){
			$(".group1").colorbox({rel:'group1',width:"100%",height:"100%"});
			$("#item_comments").hide();
			$("#sheet1").css('border-right','1px solid #ddd');
			
		});
	</script>
    <div class="ware_info">
         <div class="ware_pic"></div>
         <div id="slider" class="slider" style="overflow: hidden; visibility: visible; list-style: none outside none; position: relative;">
             <ul id="sliderlist" class="sliderlist" style="position: relative; overflow: hidden; transition: left 600ms ease 0s; width: 784px; left: 202px;">
                 <volist name="img_list" id="img">
                     <li style="float: left; display: block; width: 596px;"><a class="group1" href="{:$img['url']}"><img class="goods-img"  width="90%" height="90%" src="{:$img['url']}"></li>
                 </volist>
             </ul>
            <div id="pagenavi">
                <volist name="img_list" id="img" key='k'>
                    <a href="javascript:void(0);" <if condition='$k eq 1'>class="active"</if>>{$k}</a>
                </volist>
            </div>
         </div>
         <script type="text/javascript">
         var active=0,
             as=document.getElementById('pagenavi').getElementsByTagName('a');
             
         for(var i=0;i<as.length;i++){
             (function(){
                 var j=i;
                 as[i].onclick=function(){
                     t2.slide(j);
                     return false;
                 }
             })();
         }
         var t2=new TouchSlider({id:'sliderlist', speed:600, timeout:6000, before:function(index){
                 as[active].className='';
                 active=index;
                 as[active].className='active';
             }});
		         
         </script>
         <form name="form1" id="form1" action="" method="post">
         <input type="hidden" value="{$item.id}" name="goodId" id="goodId" >
         <div class="ware_text">
             <div class="rate">
                <h2 class="ware_title">{$item.title}</h2>       	
                <h2 class="ware_title">售价：<span class="fontColor3">¥{$item.price}</span></h2>
                <span class="letter1" style="margin:0px 5px;">销量：{$item.buy_num}件</span>
                <span class="letter1" style="margin:0px 5px;">品牌：{$item.brand}</span>
                
			</div>
            <div class="handle">

           <script type="text/javascript">
           var colorchoose = "";
           var sizechoose = "";
				function sizetitle(size_title){
					sizechoose = size_title;
	            	if(colorchoose != ""){
			    		item_id=$("#goodId").val();
			    		$.get('./index.php?g=home&m=index&a=addressselect&item_id='+item_id+'&color='+colorchoose+"&size="+size_title,function(data,status){
			    			var obj = eval('('+  data +')');               		
			    			$("#detail_stock").text(obj.status);
	                	  });
			    	}
	              $(".size_title").css('background','none');
		          $("#size" + size_title).css('background','url(__STATIC__/images/xiaokuang.png)');
		          $("#sizeChoose").val(size_title);
		        }
		        function colortitle(color_title){
		        	colorchoose = color_title;
			    	if(sizechoose != ""){
			    		item_id=$("#goodId").val();
			    		$.get('./index.php?g=home&m=index&a=addressselect&item_id='+item_id+'&color='+color_title+"&size="+sizechoose,function(data,status){
			    			var obj = eval('('+  data +')');               		
			    			$("#detail_stock").text(obj.status);
	                	  });
			    	}
		        	
		        	
	              $(".color_title").css('background','none');
		          $("#color" + color_title).css('background','url(__STATIC__/images/xiaokuang.png)');
		          $("#colorChoose").val(color_title);
		        }
		  </script>
		  <style>
		       .size_title{border:1px solid #d9d9d9;color:black;width:75px;height:24px;background:none;font-size:14px;float:left;margin:5px;}
		       .color_title{border:1px solid #d9d9d9;color:black;width:75px;height:24px;background:none;font-size:14px;float:left;margin-left:5px;}
		  </style>
                <ul><li class="handle_title">请选择：</li><li class="handle_title" style="color:black;">颜色/尺码</li></ul>
                
                <if condition="$countColor eq 0">
                	<input name="color" id="colorChoose" type="hidden" value="无">
                <else/>
                <ul style="font-size:12px; font-color:#999; margin-bottom:10px;">
                    <li style="margin-right:10px; margin-top:5px;">颜色</li>
                    <li>
                    <volist name='color' id='vo'>
                        <if condition="$vo neq ''">
                    	<a href="javascript:void(0);" onclick="colortitle('{$vo}')" ><div class="color_title" id="color{$vo}">{$vo}</div></a>
                    	</if>
                    </volist>
                    <input name="color" id="colorChoose" type="hidden" value="">
                    </li>
                </ul>

                </if>
                
                <if condition="$countSize eq 0">
                    <input name="size" id="sizeChoose" type="hidden" value="无">
                <else/>
                <ul style="font-size:12px; font-color:#999">
                	<li style="margin-right:10px;margin-top:5px;">尺码</li>

                    <li>
                    <volist name='size' id='vo'>
                    	<if condition="$vo neq ''">
                    	 <a href="javascript:void(0);" onclick="sizetitle('{$vo}')" ><div class="size_title" id="size{$vo}">{$vo}</div></a>
                    	 </if>
                    </volist>
                    <input name="size" id="sizeChoose" type="hidden" value="">
                    </li>
                </ul>
                </if>
                
                <ul  style="font-size:12px; font-color:#999;">
                    <li style="margin-right:10px;margin-top:10px;">数量</li>
                    <li style="margin-top:5px;margin-left:5px;">
                        <a style="float:left;" href="javascript:minus();"><img alt="" src="__STATIC__/images/minus.png" style="width:30px; height:30px;"></a>
                        <input type="text" value="1" id="quantity" name="quantity" style="float:left;width:70px;height:30px;line-height:normal;border:1px solid #ddd;border-left:0;border-right:0;background:#fff;font-size:16px;background:#fff;text-align:center"/>
                        <a style="float:left;" href="javascript:plus();"><img alt="" src="__STATIC__/images/plug.png" style="width:30px; height:30px;"></a>
                    </li>
                    <li style="margin-left:20px;margin-top:10px;"> 件（仅剩<span id="detail_stock" ectype="goods_stock" style="color:red;" class="stock">{$item.goods_stock}</span>件）</li>
                </ul>
                <div class="clear"></div>
            </div>
            <div class="add-g-s">加入成功</div>
            <div class="cart-buy-f">
            <ul class="ware_btn">
                <div style="display:none;" class="ware_cen">
                	
                    <div class="ware_center">
                        <h1>
                            <span class="dialog_title"></span>
                            <span onclick="slideUp_fn();" onmouseout="this.className = 'close_link'" onmouseover="this.className = 'close_hover'" title="关闭" class="close_link"></span>
                        </h1>
                        <div class="ware_cen_btn">
                            <p class="ware_text_p">购物车内共有 <span class="bold_num"></span> 种商品 共计 <span class="bold_mly"></span></p>
                            <p class="ware_text_btn">
                                <a href="{:U('shopcart/index',array('tokenTall'=>$tokenTall))}"><input type="submit" onclick="#" value="查看购物车" name="" class="btn1"></a>
                               <a href="{:U('book/allcate',array('tokenTall'=>$tokenTall))}"> <input type="submit" onclick="$('.ware_cen').css({'display':'none'});" value="继续挑选商品" name="" class="btn2"></a>
                            </p>
                        </div>
                    </div>
                    <div class="ware_cen_bottom"></div>
                </div>
                	<li style="margin-left:20%;"><a href="javascript:void(0)" onclick="javascript:buy_now();" title="立即购买" class="buy-now enter">立即购买</a></li>                
                	<li style="margin-left:5%;"><a href="javascript:void(0)" onclick="javascript:buys();" title="加入购物车" class="add-ent enter">加入购物车</a></li>
            </ul>
            </div>
        </div>
        <div class="clear"></div>
        </form>
    </div>
    <a name="module"></a>
    <ul class="user_menu">
        <div class="ornament1"></div>
        <div class="ornament2"></div>
	<!--xxl start-->
        <li class="btn_1 active" id = "sheet1"><a href="javascript:showinfo(1);"><span>商品详情</span></a></li>
        <li class="btn_2" id = "sheet2"><a href="javascript:showinfo(2);"><span>商品评论</span></a></li>
	<!--xxl end-->
    </ul>
	<div class="option_box" id = "item_info">		 
			<div class="default">
			{$item.info}
			</div>
	</div>
	<!--xxl start-->
	<div class="option_box" id = "item_comments">
	<table style = "width:100%;border-collapse:collapse;" border="1">	
		<volist name='comments_list' id='vo' mod='2'>
		<eq name="mod" value="1">
		<tr style="background: lightgrey;">
		<else />
		<tr style="background: lightgrey">
		</eq>
			<td style="padding:10px; border:0px;"><label><font size="1px">{$vo.create_time}</font></label></td>
			<td style="text-align:center; border:0px;"><label><font size="1px">{$vo.user_name}</font></label></td>
			<td style="text-align:center; border:0px;"><label><font size="1px">评价等级:
				<switch name="vo.comments_type" >
					<case value="1">好</case>
					<case value="2">中</case>
					<default />差  
				</switch>
			</font></label></td>
		</tr>
		<tr style="background: pink;" >
			<td colspan="3" style="padding:10px"><label><font size="1px">评价内容：{$vo.user_comments}</font></label></td>
		</tr>
		</div>
		</volist>			
	</table>		
	</div>		
	<!--xxl end-->
	    
    <div class="clear"></div>
</div>

<include file="public:footer" />
<div class="foot-bot"></div>
</body>
</html>
